﻿@model Merp.Web.UI.Areas.Accountancy.Models.JobOrder.IndexViewModel
@{
    ViewBag.Title = "Index";
}
<script>
    (function () {
        var homePageApp = angular.module('myApp', []);
    }());
    (function (module) {
        var jobOrdersController = function ($scope, $http) {
            $scope.refreshJobOrdersList = function () {
                var url = '/Accountancy/JobOrder/GetList?currentOnly=' + $scope.currentOnly;
                $http.get(url).success(function (data) {
                    $scope.JobOrders = data;
                });
            }
            $scope.refreshJobOrdersList();
        }
        module.controller('jobOrdersController', ['$scope', '$http', jobOrdersController]);
    }(angular.module('myApp')))
</script>
<div class="row">
    <h2>Index</h2>
    <div id="JobOrdersBox" class="col-md-10 pull-left" data-ng-app="myApp">

        <div id="JobOrdersTab" data-ng-controller="jobOrdersController">
            @*<div class="form-group">
                @Html.LabelFor(model => model.CurrentOnly, htmlAttributes: new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CurrentOnly, new { htmlAttributes = new { @class = "form-control" } })
                    @Html.ValidationMessageFor(model => model.CurrentOnly, "", new { @class = "text-danger" })
                </div>
            </div>*@
            <div class="checkbox">
                <label>
                    <input type="checkbox" id="currentOnly" data-ng-model="currentOnly" data-ng-click="refreshJobOrdersList()" /> Current only
                </label>
            </div>
            <label for="JobOrdersTable">Current Job orders</label>&nbsp;(<a id="refreshJobOrdersList" data-ng-click="refreshJobOrdersList()">refresh</a>)
            <table id="JobOrdersTable" class="table table-striped">
                <thead>
                    <tr>
                        <td>Customer name</td>
                        <td>Job Order name</td>
                    </tr>
                </thead>
                <tbody>
                    <tr data-ng-repeat="jobOrder in JobOrders">
                        <td>{{jobOrder.CustomerName}}</td>
                        <td><a href="/Accountancy/JobOrder/Detail/{{jobOrder.OriginalId}}">{{jobOrder.Name}}</a></td>
                    </tr>
                </tbody>
            </table>
        </div>

    </div>
    <div id="CommandsBox" class="col-md-2 pull-right">
        <ul class="list-unstyled">
            <li><a href="/Accountancy/JobOrder/CreateFixedPrice">Create fixed price Job Order</a></li>
            <li><a href="/Accountancy/JobOrder/CreateTimeAndMaterial">Create time and material Job Order</a></li>
        </ul>
    </div>
</div>

